export function lineChart(data, options){//折线图
    var echarts = require('echarts');
    // let  data1= JSON.parse(JSON.stringify(data));
    var series = [];
    var tooltip = {
        trigger: 'none',
        axisPointer: {
            type: 'cross'
        }
    };
    for(var i = 0;i<options.legend.length;i++){
        if(i===0){
            let obj = {
                name: options['legend'][i],
                data: data['data'+i] || data,
                type: 'line',
                lineStyle: options['lineStyle'],
                smooth: options['smooth'] || ''
            };
            options['symbol']? obj['symbol'] = options['symbol'] : '';
            options['symbolSize']? obj['symbolSize'] = options['symbolSize'] : '';
            series.push(obj)
        }else{
            let obj ={
                name: options['legend'][i],
                data: data['data'+i],
                type: 'line',
                lineStyle: options['lineStyle'],
                smooth: options['smooth'] || ''
            };
            options['symbol']? obj['symbol'] = options['symbol'] : '';
            options['symbolSize']? obj['symbolSize'] = options['symbolSize'] : '';
            series.push(obj)
        }
    }
   console.log()
    var option = {
        color: options['color'],
        legend: {
            data: options['legend'],
            top: options['top'] || 20,
            selectedMode: options['selectedMode'] || true, //图例模式默认选多个
            selected: options['selected'] //默认显示指定个数图例
        },
        grid: options['grid'] || {},
        tooltip: options['tooltip'] || tooltip,
        title: options['title']|| '',
        xAxis: options.xAxis || '',
        yAxis: options.yAxis || '',
        series: series
    };
    if(!document.getElementById(options['id'])){return false;}
    let myChart = echarts.init(document.getElementById(options['id']))
	myChart.clear();
	myChart.setOption(option);
}
export default lineChart = lineChart;

